﻿@using System.Globalization
@model ProductDetailsModel
<div class="row">
    <div class="form-group col-12">
        @if (Model.EndTime.HasValue)
        {
            <div class="countdown-box alert alert-info">
                @if (Model.EndTime > DateTime.UtcNow)
                {
                    <countdown :end-time="@Model.EndTime.Value.Subtract(new DateTime(1970, 1, 1, 0, 0, 0, DateTimeKind.Utc)).TotalMilliseconds">
                        <template v-slot:process="{ timeObj }">
                            <span class="col-form-label">@Loc["AddToCart.Timeleft"]</span>
                            <span>{{ `${timeObj.d}` }}</span>
                            <span>{{ `${timeObj.h}` }}</span>
                            <span>{{ `${timeObj.m}` }}</span>
                            <span>{{ `${timeObj.s}` }}</span>
                        </template>
                        <template v-slot:finish>
                            <span>@Loc["ShoppingCart.Auctionends"]</span>
                        </template>
                    </countdown>
                }
                else
                {
                    <div class="d-inline-flex flex-wrap justify-content-center">
                        <label class="ended-label mb-0">@Loc["ShoppingCart.Auctionends"]:</label>
                        <div class="count-date">@Model.EndTimeLocalTime!.Value.ToString(CultureInfo.InvariantCulture)</div>
                    </div>
                }
            </div>
        }
        @if (Model.EndTime > DateTime.UtcNow)
        {
            <div class="btn-group w-100 mt-3">
                <input name="HighestBidValue" type="number" class="form-control" value="@(Model.HighestBidValue > 0 ? (Model.HighestBidValue + 1).ToString(CultureInfo.InvariantCulture) : (Model.StartPrice + 1).ToString(CultureInfo.InvariantCulture))"/>
                <button id="bid-button-@Model.Id" class="btn btn-info add-to-cart-button d-inline-flex align-items-center" data-productid="@Model.Id" onclick="AxiosCart.addbid('@Url.RouteUrl("AddBid", new { productId = Model.Id })', @($"'#product-details-form-{Model.Id}'")); return false;">
                    <b-icon icon="hammer" class="mx-1"></b-icon><span>@Loc["ShoppingCart.Bid"]</span>
                </button>
            </div>
        }
    </div>
</div>